import { _decorator, Component, Animation, Node, Label } from 'cc';
import { Config } from './Config';
import { SDKManager } from './SDKManager';
const { ccclass, property } = _decorator;

@ccclass('msgGameWin')
export class msgGameWin extends Component {

    @property(Animation)
    public anim: Animation = null!;

    @property(Node)
    public mask: Node = null!;

    @property(Label)
    public level:Label=null!

    start() {
        this.mask.setScale(1, Config.heightScaling)
    }

    show(i:number) {
        this.level.string=`通过第 ${i} 关！`
        this.node.active = true
        this.anim?.play('pop-up');
        SDKManager.showInterstitialAd(3);
    }

    hide() {
        this.anim?.play('pop-out');
        this.anim.on(Animation.EventType.STOP, this.onAnimationStop, this);
    }

   
    onAnimationStop() {
        this.node.active = false;
        this.anim.off(Animation.EventType.STOP, this.onAnimationStop, this);
    }

}
